//
//  HomePageCell.m
//  Logistics
//
//  Created by enzhoukeji on 2018/8/6.
//  Copyright © 2018年 puyue.com. All rights reserved.
//

#import "HomePageCell.h"

@implementation HomePageCell
-(void)loadViews {
    self.provenanceL = [UILabel labelWithSize:[UIFont systemFontOfSize:GTFixHeightFlaot(13)] withColor:[UIColor blackColor] withText:@"济南"];
    self.arrowImage = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"tianjiatupian"]];
    self.destinationL = [UILabel labelWithSize:[UIFont systemFontOfSize:GTFixHeightFlaot(13)] withColor:[UIColor blackColor] withText:@"北京  通州"];
    self.lengthL = [UILabel labelWithSize:[UIFont systemFontOfSize:GTFixHeightFlaot(10)] withColor:[UIColor grayColor] withText:@"2.2米"];
    self.typeL = [UILabel labelWithSize:[UIFont systemFontOfSize:GTFixHeightFlaot(10)] withColor:[UIColor grayColor] withText:@"冷藏"];
    self.miscellaneousL = [UILabel labelWithSize:[UIFont systemFontOfSize:GTFixHeightFlaot(10)] withColor:[UIColor grayColor] withText:@"好多类型我也不确定要搞几个"];
    self.timeL = [UILabel labelWithSize:[UIFont systemFontOfSize:GTFixHeightFlaot(10)] withColor:[UIColor grayColor] withText:@"8：30"];
    self.toViewL = [UILabel labelWithSize:[UIFont systemFontOfSize:GTFixHeightFlaot(10)] withColor:[UIColor grayColor] withText:@"88人已查看"];
    
    
    self.TheSpecifiedBut = [UIButton buttonWithTitle:@"指定司机" withImageName:nil withBGColor:[UIColor whiteColor] Withlayer:NO];
    [self.TheSpecifiedBut setTitleColor:[UIColor colorWithRed:63/255.0 green:63/255.0 blue:63/255.0 alpha:1] forState:UIControlStateNormal];
    [self.TheSpecifiedBut addTarget:self action:@selector(TheSpecifiedButtonClieck:) forControlEvents:UIControlEventTouchUpInside];
    [self.TheSpecifiedBut.layer setBorderWidth:.2]; //边框宽度
    self.TheSpecifiedBut.layer.borderColor = [UIColor colorWithRed:63/255.0 green:63/255.0 blue:63/255.0 alpha:1].CGColor;
    self.TheSpecifiedBut.titleLabel.font = [UIFont systemFontOfSize:GTFixHeightFlaot(12)];
    
    
     self.refreshBut = [UIButton buttonWithTitle:@"刷新置顶" withImageName:nil withBGColor:[UIColor whiteColor] Withlayer:NO];
     [self.refreshBut addTarget:self action:@selector(refreshButtonClieck:) forControlEvents:UIControlEventTouchUpInside];
    [self.refreshBut setTitleColor:[UIColor colorWithRed:63/255.0 green:63/255.0 blue:63/255.0 alpha:1] forState:UIControlStateNormal];
    [self.refreshBut.layer setBorderWidth:.2]; //边框宽度
    self.refreshBut.layer.borderColor = [UIColor colorWithRed:63/255.0 green:63/255.0 blue:63/255.0 alpha:1].CGColor;
    self.refreshBut.titleLabel.font = [UIFont systemFontOfSize:GTFixHeightFlaot(12)];
    
    
    self.deleteBut = [UIButton buttonWithTitle:@"删除" withImageName:nil withBGColor:[UIColor whiteColor] Withlayer:NO];
    [self.deleteBut addTarget:self action:@selector(deleteButtonClieck:) forControlEvents:UIControlEventTouchUpInside];
    [self.deleteBut setTitleColor:[UIColor colorWithRed:63/255.0 green:63/255.0 blue:63/255.0 alpha:1] forState:UIControlStateNormal];
    [self.deleteBut.layer setBorderWidth:.2]; //边框宽度
    self.deleteBut.layer.borderColor = [UIColor colorWithRed:63/255.0 green:63/255.0 blue:63/255.0 alpha:1].CGColor;
    self.deleteBut.titleLabel.font = [UIFont systemFontOfSize:GTFixHeightFlaot(12)];
    
     self.oftenBut = [UIButton buttonWithTitle:@"常发货源" withImageName:nil withBGColor:[UIColor whiteColor] Withlayer:NO];
    [self.oftenBut addTarget:self action:@selector(oftenButtonClieck:) forControlEvents:UIControlEventTouchUpInside];
    [self.oftenBut setTitleColor:[UIColor colorWithRed:63/255.0 green:63/255.0 blue:63/255.0 alpha:1] forState:UIControlStateNormal];
    [self.oftenBut.layer setBorderWidth:.2]; //边框宽度
    self.oftenBut.layer.borderColor = [UIColor colorWithRed:63/255.0 green:63/255.0 blue:63/255.0 alpha:1].CGColor;
    self.oftenBut.titleLabel.font = [UIFont systemFontOfSize:GTFixHeightFlaot(12)];
    
    self.grayL = [UILabel labelWithSize:[UIFont systemFontOfSize:GTFixHeightFlaot(10)] withColor:[UIColor colorWithRed:197/255.0 green:197/255.0 blue:197/255.0 alpha:1] withText:nil];
    self.grayL.backgroundColor = [UIColor colorWithRed:197/255.0 green:197/255.0 blue:197/255.0 alpha:1];
    
    [self addSubview:self.provenanceL];
    [self addSubview:self.arrowImage];
    [self addSubview:self.destinationL];
    [self addSubview:self.lengthL];
    [self addSubview:self.typeL];
    [self addSubview:self.miscellaneousL];
    [self addSubview:self.timeL];
    [self addSubview:self.toViewL];
    [self addSubview:self.TheSpecifiedBut];
    [self addSubview:self.refreshBut];
    [self addSubview:self.deleteBut];
    [self addSubview:self.oftenBut];
    [self addSubview:self.grayL];
}
-(void)layoutViews {
    [self.provenanceL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(@(GTFixHeightFlaot(8)));
        make.left.equalTo(@(GTFixWidthFlaot(15)));
        make.height.equalTo(@(GTFixHeightFlaot(20)));
        make.width.equalTo(@(GTFixWidthFlaot(35)));
    }];
    [self.arrowImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.provenanceL.mas_right);
        make.centerY.equalTo(self.provenanceL.mas_centerY);
        make.height.equalTo(@(GTFixHeightFlaot(15)));
        make.width.equalTo(@(GTFixWidthFlaot(15)));
    }];
    [self.destinationL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.arrowImage.mas_right);
        make.centerY.equalTo(self.provenanceL.mas_centerY);
        make.height.equalTo(@(GTFixHeightFlaot(20)));
        make.width.equalTo(@(GTFixWidthFlaot(80)));
    }];
    [self.lengthL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.provenanceL.mas_bottom).offset(10);
        make.left.equalTo(@(GTFixWidthFlaot(15)));
        make.height.equalTo(@(GTFixHeightFlaot(15)));
        make.width.equalTo(@(GTFixWidthFlaot(30)));
    }];
    [self.typeL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.lengthL.mas_right);
        make.centerY.equalTo(self.lengthL.mas_centerY);
        make.height.equalTo(@(GTFixHeightFlaot(15)));
        make.width.equalTo(@(GTFixWidthFlaot(30)));
    }];
    [self.miscellaneousL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.typeL.mas_right);
        make.centerY.equalTo(self.lengthL.mas_centerY);
        make.height.equalTo(@(GTFixHeightFlaot(15)));
        make.width.equalTo(@(GTFixWidthFlaot(150)));
    }];
    [self.timeL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.miscellaneousL.mas_right);
        make.centerY.equalTo(self.lengthL.mas_centerY);
        make.height.equalTo(@(GTFixHeightFlaot(15)));
        make.width.equalTo(@(GTFixWidthFlaot(35)));
    }];
    [self.toViewL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.lengthL.mas_bottom).offset(5);
        make.left.equalTo(@(GTFixWidthFlaot(15)));
        make.height.equalTo(@(GTFixHeightFlaot(15)));
        make.width.equalTo(@(GTFixWidthFlaot(80)));
    }];
    [self.TheSpecifiedBut mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.mas_left).offset(GTFixWidthFlaot(-1));
        make.top.mas_equalTo(self.toViewL.mas_bottom).offset(5);
        make.bottom.mas_equalTo(self.mas_bottom).offset(GTFixHeightFlaot(-2));
        make.width.mas_equalTo(@(kMainScreen_width/4));
    }];
    [self.refreshBut mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.TheSpecifiedBut.mas_right);
        make.top.mas_equalTo(self.toViewL.mas_bottom).offset(5);
        make.bottom.mas_equalTo(self.mas_bottom).offset(GTFixHeightFlaot(-2));
        make.width.mas_equalTo(@(kMainScreen_width/4));
    }];
    [self.deleteBut mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.refreshBut.mas_right);
        make.top.mas_equalTo(self.toViewL.mas_bottom).offset(5);
        make.bottom.mas_equalTo(self.mas_bottom).offset(GTFixHeightFlaot(-2));
        make.width.mas_equalTo(@(kMainScreen_width/4));
    }];
    [self.oftenBut mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.deleteBut.mas_right);
        make.top.mas_equalTo(self.toViewL.mas_bottom).offset(5);
        make.bottom.mas_equalTo(self.mas_bottom).offset(GTFixHeightFlaot(-2));
        make.width.mas_equalTo(@(kMainScreen_width/4 + 2));
    }];
    [self.grayL mas_makeConstraints:^(MASConstraintMaker *make) {
         make.top.equalTo(self.TheSpecifiedBut.mas_bottom).offset(0);
        make.left.mas_equalTo(GTFixWidthFlaot(0));
        make.height.mas_equalTo(GTFixHeightFlaot(2));
        make.width.mas_equalTo(kMainScreen_width);
    }];
    
}
-(void)setIndexPath:(NSIndexPath *)indexPath{
    _indexPath = indexPath;
}
-(void)TheSpecifiedButtonClieck:(UIButton *)btn {
    if (self.delegate) {
        [self.delegate homePagewithIndexPath:self.indexPath withtype:@"1"];
    }
}
-(void)refreshButtonClieck:(UIButton *)btn {
    if (self.delegate) {
        [self.delegate homePagewithIndexPath:self.indexPath withtype:@"2"];
    }
}
-(void)deleteButtonClieck:(UIButton *)btn {
    if (self.delegate) {
        [self.delegate homePagewithIndexPath:self.indexPath withtype:@"3"];
    }
}
-(void)oftenButtonClieck:(UIButton *)btn {
    if (self.delegate) {
        [self.delegate homePagewithIndexPath:self.indexPath withtype:@"4"];
    }
}

@end








